# 统计自己有多少个工具
class tools:
    # 类下面 定义的变量，类变量
    count = 0

    def __init__(self, name):
        self.name = name
        print(f'我现在有个工具是{self.name}')
        tools.count += 1  # 在方法中，使用类变量，类名.变量名


t1 = tools(name='剪刀')  # 实例化对象
t2 = tools(name='锤子')  # 实例化对象

# 类变量 使用 类名.变量名
print(tools.count)


# ----------------------------------------------------------------------------------
# 封装、继承、多态
# 不同的 子类 调用相同的父类，产生不同的结果
class dog():

    def __init__(self, name):
        self.name = name

    def game(self):
        print('普通的狗，只能简单的玩')


class GodDog(dog):
    def game(self):
        print('神狗要去天上玩...')


class person:
    def __init__(self, name):
        self.name = name

    def game_with_dog(self, which_dog):
        print(f'{self.name}和{which_dog.name}一起玩')
        which_dog.game()


wangcai = dog(name='旺财')
xtq = GodDog(name='哮天犬')
xiaoming = person('小明')
xiaoming.game_with_dog(which_dog=xtq)


# ----------------------------------------------------------------------------------------

# 私有方法
class woman():

    def __init__(self, name):
        self.name = name
        # 私有属性、变量
        # self.__变量名
        self.__age = 18

    def __myage(self):
        print(f'我的年龄是{self.__age}')


t1 = woman(name='张三')

# ----------------------------------------------------------------------------------------
